﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using nvn.Core.MVP;
using Hutech.CRM.Library.Views;
using Hutech.CRM.Library.Models.BusinessAccessLayer;
using Hutech.CRM.Library.Models.BusinessAccessLayer.BusinessObjects;
using Hutech.CRM.Library.Models.Entities;
using nvn.Library.Patterns;
using Hutech.CRM.Library.Utilities;

namespace Hutech.CRM.Library.Presenters
{
    public class SearchCustomerPresenter : BasePresenter<ISearchCustomerView>
    {
        #region First Description
        public SearchCustomerPresenter(ISearchCustomerView view)
            : base(view)
        {
            this.view.FristLoadEventHandler += new EventHandler<EventArgs>(view_FristLoadEventHandler);
        }


        #endregion

        #region All Event
        void view_FristLoadEventHandler(object sender, EventArgs e)
        {
            RefreshAllControl();
        }
       
        #endregion

        #region private method
        List<TowTypeParameters<Guid, string>> LoadJobs()
        {
            IAllCategoriesBAL itemBAL = new AllCategoriesBAL();
            return itemBAL.GetAllItemOfGroupCategoryForDropDownList(ConstantVariable.CATEGORY_JOB,"Lọc theo Ngành nghề");
        }
        List<TowTypeParameters<Guid, string>> LoadProvinces()
        {
           AllCategoriesBAL itemBAL = new AllCategoriesBAL();
            return itemBAL.GetAllItemOfGroupCategoryForDropDownList(ConstantVariable.CATEGORY_PROVINCEORCITY,"Lọc theo Tỉnh thành phố");
        }
        List<TowTypeParameters<Guid, string>> LoadLevels()
        {
            ICriterionCustomerBAL itemBAL = new CriterionCustomerBAL();
            return itemBAL.GetGroupLevelCustomers("Lọc theo Level");
        }
        List<TowTypeParameters<Guid, string>> LoadPositions()
        {
            AllCategoriesBAL itemBAL = new AllCategoriesBAL();
            return itemBAL.GetAllItemOfGroupCategoryForDropDownList(ConstantVariable.CATEGORY_POSITION,"Lọc theo Chức vụ");
        }
        void RefreshAllControl()
        {
            view.TextSearch = string.Empty;
            view.Jobs = LoadJobs();
            view.Positions = LoadPositions();
            view.Provinces = LoadProvinces();
            view.Levels = LoadLevels();
        }
        #endregion
    }
}
